﻿
using System;
using System.Globalization;
using System.Windows.Data;
using System.Windows.Media.Imaging;
using NetBay.Core.BusinessEntities.ActiveDirectory;

namespace Rio.Manager.Application.Converters
{
    public class AdObjectTypeGroupRioTypeImageConverter : IValueConverter
    {
        #region Methods

        /// <summary>
        /// Convert the AdObjectType in image url for to display the Rio Group type.
        /// </summary>
        /// <param name="value"></param>
        /// <param name="targetType"></param>
        /// <param name="parameter"></param>
        /// <param name="culture"></param>
        /// <returns></returns>
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (value != null)
            {
                if (AdObjectType.User.ToString() == value.ToString())
                {
                    return new Uri("/Rio.Manager.Application;component/Assets/Images/user.png", UriKind.Relative);
                }
                else if (AdObjectType.Group.ToString() == value.ToString())
                {
                    return new Uri("/Rio.Manager.Application;component/Assets/Images/group.png", UriKind.Relative);
                }
                else
                {
                    return value;
                }
            }
            else
            {
                return value;
            }
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            throw new NotSupportedException();
        }

        #endregion Methods
    }
}